<%@ page contentType="text/html;charset=UTF-8" language="java" trimDirectiveWhitespaces="true" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="format-detection" content="telephone=no">
    <meta name="format-detection" content="email=no">
    <title>荩美国际商城</title>
    <link href="/resources/frontcss/321.css" rel="stylesheet">
    <script src="/resources/js/jquery-1.8.1.min.js" type="text/javascript"></script>
</head>
<body>

<div class="contain-all">
    <div class="contain-img">
        <div class="share-tap">点击此处分享到朋友圈</div>
        <div class="share-add">
            <p>分享时，请写上</p>
            <p>“产品高大上，我已经领取了！”</p>
            <p>分享后请填写物流信息领取</p>
        </div>
        <div class="takeshare-num">
            <div class="takeshare-num-det" align="center" id="sum_user">12,345</div>
            <div class="takeshare-num-info" align="center">今日已领取</div>
        </div>
        <div class="takeshare-show">
            <div class="takeshare-show-info" align="center" style="">
               <%-- <p>张**(手机150****3851)3秒前 成功领取</p>
                <p>李**(手机151****9657)18秒前 成功领取</p>
                <p>孙**(手机153****7534)35秒前 成功领取</p>
                <p>陈**(手机135****4287)39秒前 成功领取</p>--%>
               </div>
        </div>
        <img class="frontpage-imgs" src="/resources/images/3of1-1.jpg">
    </div>
</div>

<script>
    wtop = -20;
    wnum = 0;
    infowidth = $('.takeshare-show-info').width();
    $('.takeshare-show-info').css('margin-left',($(window).width()-infowidth)/2);
    function wordmove(){
        $('.takeshare-show-info').css('top',wtop);
        $('.takeshare-show-info').children('p').eq(wnum).clone().appendTo('.takeshare-show-info');
        wtop = wtop - 20;
        wnum = wnum + 1;
    }
    wordmove();
    setInterval(function(){
        wordmove();
    },1500);

</script>
<script type="text/javascript" src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js" charset="utf-8"></script>
<script type="text/javascript">

    var linkUrl ;
    var shareTitle;
    var shareDesc;
    var fxImage = "";
    function wxConfig(reset) {
        var url = window.location.href;
        url = url.split('#')[0];
        $.ajax({
            url: '/front/getShareConfig',
            data: {url: url},
            dataType: 'json',
            type: 'post',
            success: function (res) {
                if (res.success) {
                    var d = res.data;
                    shareTitle = d.shareTitle;
                    shareDesc = d.shareDesc;
                    fxImage = d.shareImg;
                    lineLink = d.lineLink;
                    wx.config({
                        debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来，若要查看传入的参数，可以在pc端打开，参数信息会通过log打出，仅在pc端时才会打印。
                        appId: d.appId, // 必填，公众号的唯一标识
                        timestamp: d.timestamp, // 必填，生成签名的时间戳
                        nonceStr: d.nonceStr, // 必填，生成签名的随机串
                        signature: d.signature,// 必填，签名，见附录1
                        jsApiList: ['onMenuShareTimeline', 'onMenuShareAppMessage',
                            'onMenuShareQZone', 'onMenuShareQQ', 'onMenuShareWeibo'
//                            'checkJsApi','getLocation'
                        ] // 必填，需要使用的JS接口列表，所有JS接口列表见附录2
                    });
                }
            }
        });
    }

    wxConfig(false);

    wx.ready(function () {
        //分享给朋友
        wx.onMenuShareAppMessage({
            title: shareTitle,
            desc: shareDesc,
            link: linkUrl,
            imgUrl: fxImage,
            success: function (res) {
                alert('已分享');
            },
            cancel: function (res) {
                alert('已取消');
            },
            fail: function (res) {
                alert(JSON.stringify(res));
            }
        });

        //分享到朋友圈
        wx.onMenuShareTimeline({
            title: shareTitle,
            link: linkUrl,
            desc: shareDesc,
            imgUrl: fxImage,
            success: function (res) {
                alert('已分享');
                //记录分享内容
                shareRecord();
            },
            cancel: function (res) {
                alert('已取消');
            },
            fail: function (res) {
                alert(JSON.stringify(res));
            }
        });
        wx.onMenuShareQQ({
            title: shareTitle, // 分享标题
            desc: shareDesc, // 分享描述
            link: linkUrl, // 分享链接
            imgUrl: fxImage, // 分享图标
            success: function () {
                // 用户确认分享后执行的回调函数
                alert('已分享');
            },

            cancel: function () {
                // 用户取消分享后执行的回调函数
                alert('已取消');
            }

        });
    });

    wx.error(function (res) {
        if (res.errMsg == "config:invalid signature") {
            wxConfig(true);
        } else {
            alert(res.errMsg);
        }
    });

    function shareRecord(){
        $.ajax({
            url:"/front/user/share?r="+Math.random(),
            type:"post",
            success:function(res){
                if(res.success){
                    window.location.href = "/front/cartList";
                }
            },
            error:function(){}
        })
    }
</script>
</body>
</html>